﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;


namespace HappyHour.MyTasks.Client.UI.Metro.Converters
{
    public class DateTimeToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var date = DateTime.Parse(value.ToString());
            return date;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            DateTime parsedDate;
            if (DateTime.TryParse(value.ToString(), out parsedDate))
            {
                return parsedDate;
            }
            else
            {
                return DateTime.MaxValue;
            }

        }
    }
}
